//收藏
Vue.component('col_post', {
	props: ['collection_type'],
	template: '<div class="post_list">\
					<!--帖子列表-->\
					<div class="community_news" v-show="collection_type==0">\
						<div class="content cursor" @click="go_detail(item,0)" v-for="(item,index) in forum">\
							<!--上半部分-->\
							<div>\
							<img :src="item.HeadImg ? (host+item.HeadImg) : \'imgs/icon.jpg\'" onerror="globalData.utils.imgLoadErr(event)" alt="" />\
								<div class="my_flex my_flex_col">\
									<span @click="detail(item.ID)">{{item.Title | cut_text(40)}}</span>\
									<span>{{item.CreateTimeText}}</span>\
								</div>\
							</div>\
							<div>\
								<span v-html="item.Content"></span>\
							</div>\
							<div>\
								<!--循环图片,返回数所中没有图片-->\
							</div>\
							<!--下半部分-->\
							<div class="icons my_flex">\
								<li class="my_flex my_flex_center"><img  src="imgs/community/like.png" alt="" />{{item.Like}}</li>\
								<li class="my_flex my_flex_center"><img  src="imgs/community/unlike.png" alt="" />{{item.Unlike}}</li>\
								<li class="my_flex my_flex_center"><img  src="imgs/community/back.png" alt="" />{{item.ReplyCount}}</li>\
							</div>\
						</div>\
					</div>\
					<!--新闻列表-->\
					<div class="community_news news_lists" v-show="collection_type==1">\
						<div class="content cursor" @click="go_detail(item,1)" v-for="(item,index) in news">\
							<!--上半部分-->\
							<div>\
								<img v-if="item.HeadImg" :src="item.HeadImg ? (host+item.HeadImg) : \'imgs/icon.jpg\'" onerror="globalData.utils.imgLoadErr(event)" alt="" />\
								<div class="my_flex my_flex_col" :class="[{no_headimg:!item.HeadImg}]">\
									<span @click="detail(item.ID)">{{item.Title | cut_text(48)}}</span>\
									<span>{{item.CreateTimeText }}</span>\
								</div>\
							</div>\
							<div :class="[{no_headimg:!item.HeadImg}]">\
								<span>{{item.Content | translate_text(80)}}</span>\
							</div>\
							<div>\
								<!--循环图片,返回数所中没有图片-->\
							</div>\
							<!--下半部分-->\
							<div class="icons my_flex">\
								<li class="my_flex my_flex_center"><img  src="imgs/community/like.png" alt="" />{{item.Like}}</li>\
								<li class="my_flex my_flex_center"><img  src="imgs/community/unlike.png" alt="" />{{item.Unlike}}</li>\
								<li class="my_flex my_flex_center"><img  src="imgs/community/back.png" alt="" />{{item.ReplyCount}}</li>\
							</div>\
						</div>\
					</div>\
					<!--<change-page :current_page="page.pageIndex" :page_size="page.pageSize" :page_total="page.pageTotal" @page-change="getPageMyFavorites"></change-page>-->\
				</div>',
	data: function() {
		return {
			host:globalData.constParam.url.baseUrl+'/',
			url: {
				getPageMyFavorites: '/api/MyFavorites/GetPageMyFavorites', //获取收藏
			},
			forum: [], //论坛列表
			news:[], //新闻列表
			page: {
				pageIndex: 1,
				pageSize: 100,
				pageTotal: 0
			}
		}
	},
	mounted: function() {
		this.getPageMyFavorites(this.page.pageIndex, this.page.pageSize);
	},
	methods: {
		//获取数据
		getPageMyFavorites: function(curPage, pageSize) {
			var that = this;
			var data = {
				PageIndex: curPage,
				PageSize: pageSize
			};
			globalData.ajaxPost(this.url.getPageMyFavorites, data, function(res) {
				var d = res.data;
				if(res.suc){
					console.log(d)
					that.forum = []
					$.each(d, function(index,item) {
						if(item.FavoriteType==2){
							that.forum.push(item)
						}else if(item.FavoriteType==1){
							that.news.push(item)
						}
					});
				}
			})
		},
		//收藏帖子
		addForumFavorites: function(index) {
			
		},
		//赞和踩
		like: function(index, num) {
			
		},
		//帖子回复
		addForum: function(idnex) {
			
		},
		detail:function(id){
			globalData.utils.setUrl("news_detail.html",{id:id});
		},
		//去详情页
		go_detail: function(item,index) {
			var obj = {
				id:item.ForumID
			}
			if(index==0){
				var url = "forum_datail.html"
			}else if(index==1){
				var url = "news_detail.html"
			}
			
			globalData.utils.setUrl(url,obj)
			
		}
	}
});